package com.huika.renrench.control.my.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.huika.lib.utils.MoneyShowTool;
import com.huika.renrench.R;
import com.huika.renrench.control.common.base.BaseAct;
import com.huika.renrench.view.TitleBarHelper;

/**
 * 
 * @description：充值成功
 * @author zc
 * @date 2015年6月23日 下午5:16:08
 */
public class RechargeSuActivity extends BaseAct {

	private TextView odd_number_detail;
	private TextView money_detail;
	private TextView time_detail;
	private Button complete;
	private String orderTime;
	private String orderNo;
	private double amount;
	
	@Override
	protected void initData() {
		super.initData();
		TitleBarHelper titleBarHelper = new TitleBarHelper(this, -1);
		titleBarHelper.setLeftMsg("返回");
		titleBarHelper.setTitleMsg("充值成功");
		Intent intent = getIntent();
		orderTime = intent.getStringExtra("orderTime");
		orderNo = intent.getStringExtra("orderNo");
		amount = intent.getDoubleExtra("amount", 0);
	}
	
	@Override
	protected void initWidget() {
		super.initWidget();
		odd_number_detail = (TextView) findViewById(R.id.odd_number_detail);
		money_detail = (TextView) findViewById(R.id.money_detail);
		time_detail = (TextView) findViewById(R.id.time_detail);
		complete = (Button) findViewById(R.id.complete);
		complete.setOnClickListener(this);
		
		odd_number_detail.setText(orderNo);
		time_detail.setText(handleTime(orderTime));
		money_detail.setText(MoneyShowTool.twolastDF(amount) + "元");
	}
	
	@Override
	public void widgetClick(View v) {
		super.widgetClick(v);
		switch (v.getId()) {
			case R.id.complete:
				finish();
				break;

			default:
				break;
		}
	}
	
	private String handleTime(String time) {
		try {
			StringBuffer sb = new StringBuffer();
			sb.append(time.substring(0, 4))
			.append("-")
			.append(time.substring(4, 6))
			.append("-")
			.append(time.substring(6, 8))
			.append(" ")
			.append(time.substring(8, 10))
			.append(":")
			.append(time.substring(10, 12))
			.append(":")
			.append(time.substring(12));
			return sb.toString();
		}
		catch (Exception e) {
			return time;
		}
	}
	
	@Override
	public void setRootView() {
		setContentView(R.layout.activity_recharge_success);
	}

}
